package com.itheima.health.config;

import com.itheima.health.interceptor.LoginBackendInterceptor;
import com.itheima.health.interceptor.LoginMobileInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
@Slf4j
public class WebMvcConfig implements WebMvcConfigurer {
    /**
     * 后台拦截器
     */
    @Resource
    private LoginBackendInterceptor loginBackendInterceptor;
    @Resource
    private LoginMobileInterceptor loginMobileInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginBackendInterceptor)
                .addPathPatterns("/backend/**")
                .excludePathPatterns("/backend/user/**");
        registry.addInterceptor(loginMobileInterceptor)
                .addPathPatterns("/mobile/**")
                .excludePathPatterns("/mobile/member/**",
                        "/mobile/validatecode/**");
            }
}
